interface IEmp {
    id: number;
    name: string;
    dept: string;
}
const emps:IEmp[] = [
    { id: 1, name: "xiaowang", dept: "开发" },
    { id: 1, name: "xiaowang", dept: "开发" },
    { id: 1, name: "xiaowang", dept: "开发" }
]

function findEmpByName(name:string){
    const emp = emps.find(item=>item.name==name)
    console.log((<IEmp>emp).id);
    console.log((emp as IEmp).id);
    // console.log(emp?.id);
    // if(emp){
    //     console.log(emp.id);
    // }
    
}

